package com.bestcem.xm.component.security.configure;

import com.bestcem.xm.component.security.interceptor.LoginInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

public class XmSecurityInterceptorConfigure implements WebMvcConfigurer {

    private LoginInterceptor loginInterceptor;

    public void setLoginInterceptor(LoginInterceptor loginInterceptor) {
        this.loginInterceptor = loginInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/swagger-resources/**", "/swagger-ui/**", "/v3/**", "/error")
                .excludePathPatterns("/webjars/**", "/favicon.ico", "/doc.html")
                .excludePathPatterns("/award/v3/public")
                .excludePathPatterns("/award/v3/bonus/deliver/name")
                .excludePathPatterns("/award/v3/bonus/win/count")
                .excludePathPatterns("/award/v3/bonus/deliver/detail")
                .excludePathPatterns("/award/v3/bonus/overview")
                .excludePathPatterns("/award/v3/draw/sms/auth")
                .excludePathPatterns("/award/v3/draw/sms")

                .excludePathPatterns("/award/v3/sms/sendSmsCode")
                .excludePathPatterns("/award/v3/sms/checkSmsCode")
                .excludePathPatterns("/award/v3/awardpoint/draw")

                .excludePathPatterns("/award/v3/draw")
                .excludePathPatterns("/award/v3/bonus/entry/{request_id:[a-zA-Z0-9]{24}}")
                .excludePathPatterns("/award/v3/bonus/draw/{request_id:[a-zA-Z0-9]{24}}")
                .excludePathPatterns("/award/v3/award/{id:[a-zA-Z0-9]{24}}")
                .excludePathPatterns("/award/v3/award/requestStatsDayJob")
                .excludePathPatterns("/award/v3/multilanguage/**")

                .excludePathPatterns("/award/bonus/saas/wx_redirect/{surveyId:[a-zA-Z0-9]{24}}")

                //下面部分更新自master
                .excludePathPatterns("/member/send_member")
                .excludePathPatterns("/mq/**")
                .excludePathPatterns("/member/footprint/publish")
                .excludePathPatterns("/error")
                .excludePathPatterns("/member/test/respondent_relevant_rate_calc/{member_id}")
                .excludePathPatterns("/member/test/compile_condition");
    }
}
